package com.example.thread2.thread6;


import static jdk.nashorn.internal.objects.Global.print;

public class InnerThread2 {
    private int coutDown = 5;
    private Thread t;
    public InnerThread2(String name) {
        t = new Thread(name){
            public void run() {
                try {
                    while (true){
                        print(this);
                        if(--coutDown == 0) {
                            return;
                        }
                        sleep(10);
                    }
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            public String toString() {
                return getName() + ": " + coutDown;
            }
        };
        t.start();
    }
}